package xcmg.device.dao.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import xcmg.device.dao.entity.purchase.PurchaseRequestDetailDO;
import xcmg.device.service.vo.purchase.PurchaseInboundPrintVO;
import xcmg.device.service.vo.purchase.PurchaseMaterialsShowVO;
import xcmg.device.service.vo.purchase.PurchaseReqeustReportVO;
import xcmg.device.service.vo.purchase.PurchaseRequestReportParamVO;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface PurchaseRequestDetailMapper {
    int insert(PurchaseRequestDetailDO record);

//    int insertSelective(PurchaseRequestDetailDO record);

    int deleteByBillId (String billId);

    int deleteByBillIdMaterialsNo (@Param("billId") String billId,@Param("materialsNo")String  materialsNo,@Param("rowNo") Integer rowNo);

    List<PurchaseRequestDetailDO> list(@Param("billId")String billId);
    
    List<PurchaseRequestDetailDO> listByBIllIds(@Param("billIds")List<String> billIds);

    int update(PurchaseRequestDetailDO record);

    int updateByOriginalMaterial(PurchaseRequestDetailDO record);

    PurchaseRequestDetailDO findByBillIdAndMaterialNo(@Param("billId")String billId, @Param("materialsNo")String materialsNo, @Param("rowNo")Integer rowNo);

    BigDecimal getPurQtyByMaterialNoAndOrgId(@Param("materialsNo")String materialsNo, @Param("purchaseOrgId")String purchaseOrgId);

    int updateRowNo(@Param("billId")String billId, @Param("materialsNo")String materialsNo, @Param("rowNo")Integer rowNo);

    BigDecimal findInformQty(@Param("billId")String billId, @Param("materialsNo")String materialsNo, @Param("rowNo")Integer rowNo);

    int updateInformQty(@Param("billId")String billId, @Param("materialsNo")String materialsNo, @Param("rowNo")Integer rowNo, @Param("informQty")BigDecimal informQty);

    Integer findSendStatus(@Param("billId")String billId);

    Integer findPrintStatus(@Param("billId")String billId);

    int findInformNum(@Param("billId")String billId);

    BigDecimal leftPrintNum(@Param("billId")String billId, @Param("materialsNo")String materialsNo, @Param("rowNo")Integer rowNo);

    List<PurchaseMaterialsShowVO> listRequestMaterials(PurchaseMaterialsShowVO showVO);

    Integer listRequestMaterialsCount(PurchaseMaterialsShowVO showVO);

    int findInBoundStatus(@Param("billId")String billId);

    /**
     * 获取零件的在途库存
     *
     * @param orgId
     * @param materialsNo
     * @return
     */
    BigDecimal countTransitStock( @Param("orgId") String orgId, @Param("materialsNo") String materialsNo);

    /**
     * @Des 采购报表
     * @Date 2020/10/29 9:16
     * @Author wangzhaoyu
     * @Param [filters]
     * @Return void
     */
    List<PurchaseReqeustReportVO> purchaseRequestReport(PurchaseRequestReportParamVO filters);

    /**
     * 查询进出口机型等信息
     * @param orgId
     * @param materialsNo
     * @param billNo
     * @return
     */
    PurchaseInboundPrintVO getJckInfoByMaterialsNo(@Param("orgId") String orgId, @Param("materialsNo") String materialsNo, @Param("billNo")String billNo);

    int updateRemark(PurchaseRequestDetailDO m);
}
